package com.blue.base.demo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.Getter;

/**
 * 管理员的状态
 *
 * @author liulei
 * @version 1.0
 */
@Getter
public enum UserStatusEnum implements IEnum<String> {

    /**
     * 最好是不要放字典表了
     */
    ENABLE("ENABLE", "启用", 0), FREEZE("FREEZE", "冻结", 1), CANCEL("CANCEL", "注销", 2);

    @EnumValue
    String value;
    String message;
    Integer code;

    UserStatusEnum(String value, String message, Integer code) {
        this.value = value;
        this.message = message;
        this.code = code;
    }

    /**
     * 根据value获取枚举
     */
    public static UserStatusEnum getByValue(String value) {
        for (UserStatusEnum ms : UserStatusEnum.values()) {
            if (ms.getValue().equals(value)) {
                return ms;
            }
        }
        return null;
    }

    /**
     * 根据code获取枚举
     */
    public static UserStatusEnum getByCode(Integer code) {
        for (UserStatusEnum ms : UserStatusEnum.values()) {
            if (ms.getValue().equals(code)) {
                return ms;
            }
        }
        return null;
    }
}
